﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using 历史记录.DataAccessLayer;

namespace 历史记录.BusinessLogicLayer
{
    /// <summary>
    /// 逻辑层
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IBLL<T> : IDisposable
        where T : Model, new()
    {
        /// <summary>
        /// 数据库操作对象
        /// </summary>
        IDAL<T> DAL { get; }

        /// <summary>
        /// 开始时间
        /// </summary>
        DateTime Start { get; }

        /// <summary>
        /// 结束时间
        /// </summary>
        DateTime End { get; }

        /// <summary>
        /// 保存时长
        /// </summary>
        TimeSpan SaveSpan { get; }

        /// <summary>
        /// 删除间隔
        /// </summary>
        TimeSpan DeleteSpan { get; }

        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="insertObjs">要添加的数据</param>
        /// <returns>添加是否成功</returns>
        bool Insertable(List<T> insertObjs);

        /// <summary>
        ///查询数据
        /// </summary>
        /// <typeparam name="TResult">返回数据类型</typeparam>
        /// <param name="Select">一个应用于每个源元素的转换函数</param>
        /// <param name="start">开始日期</param>
        /// <param name="end">结束日期</param>
        /// <param name="Where">查询条件</param>
        /// <returns></returns>
        IEnumerable<IEnumerable<TResult>> Queryable<TResult>(DateTime start, DateTime end, Expression<Func<T, TResult>> Select, Expression<Func<T, bool>> Where = null) where TResult : new();

        /// <summary>
        ///查询数据
        /// </summary>
        /// <param name="start">开始日期</param>
        /// <param name="end">结束日期</param>
        /// <param name="Where">查询条件</param>
        /// <returns></returns>
        IEnumerable<IEnumerable<T>> Queryable(DateTime start, DateTime end, Expression<Func<T, bool>> Where = null);

        /// <summary>
        ///
        /// </summary>
        /// <param name="date"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        bool UpDate(DateTime date, List<T> data);
    }
}